const connect = require('connect');
const users = require('./users');
const pets = require('./pets');
const errorHandler = require('./error-handler');

const api = connect().use(users).use(pets).use(errorHandler);

connect().use(hello).use('/api', api).listen(3000);

function hello(req, res, next) {
  if (req.url.match(/^\/hello/)) {
    res.end('Hello World\n');
  } else {
    next();
  }
}
